<template>
	<view class="">
		<button type="default" :open-type='openType' class="contact" @getphonenumber="getphone"
			@chooseavatar="chooseavatar">
			<slot />
		</button>
	</view>

	<!-- 使用
	 <zh-button openType="getPhoneNumber" @getphone='getphone'>
	 	<view class="btn flex_c cf fw500 fs26 flex_c">一键登录</view>
	 </zh-button>
	 
	 share	  	 	  触发用户转发
	 contact   		  打开客服会话，如果用户在会话中点击消息卡片后返回应用，可以从 @contact 回调中获得具体信息
	 getPhoneNumber	  获取用户手机号，可以从@getphonenumber回调中获取到获取用户手机号的code
	 openSetting	  打开授权设置页
	 chooseAvatar	  获取用户头像，可以从 @chooseavatar 回调中获取到头像信息
	 -->
</template>

<script>
	import wxApplet from '@/utils/wxApplet/wxApplet.js'
	export default {
		props: {
			openType: {
				typeOf: String,
				default: ''
			},
		},
		components: {},
		data() {
			return {

			}
		},
		mounted() {

		},
		methods: {
			getphone(e) { //手机号
				if (e.detail.code) {
					this.$emit('getphone', e.detail.code)
				}
			},
			chooseavatar(e) { //头像
				if (e.detail.avatarUrl) {
					wxApplet.uploadFile(e.detail.avatarUrl).then(res => {
						if (res.code == this.status_code) {
							this.$emit('chooseavatar', res.data)
						} else {
							uni.$u.toast(res.msg)
						}
					})
				}
			}
		},
		computed: {

		},
		watch: {

		}
	}
</script>

<style lang="scss" scoped>
	.contact {
		background-color: rgba(0, 0, 0, 0) !important;
		padding: 0 !important;
		margin: 0 !important;
		border: none !important;
		box-sizing: border-box;
		display: block;
		line-height: normal;
		width: 100%;
		height: 100%;
		overflow: visible !important;
		text-align: none !important;
	}

	.contact::after {
		border: none;
	}
</style>